<template>
  <MenuNavigation />
  <div
    ref="exhibits16"
    class="jy-style-height cultural-box"
    id="exhibits-box-id"
    :style="{
      backgroundImage: `url(${publicUrls + 'free/style14/style14publicBg.png' + '?imageView2/3/format/webp'})`,
    }"
  >
    <div class="back-btn" @click="blankHome">
      <img :src="publicUrls + 'free/style14/style14BackIcon.png?imageView2/3/format/webp'" alt="" />
    </div>

    <div class="content-box">
      <div
        class="public-name"
        :style="{
          backgroundImage: `url(${publicUrls + 'free/style14/publicTitleBg.png' + '?imageView2/3/format/webp'})`,
        }"
      >
        <img :src="publicUrls + 'free/style14/publicName2.png?imageView2/3/format/webp'" alt="" />
      </div>
      <ScrollBoxCom
        color="rgba(50, 43, 37, 1)"
        v-if="Scrollwidth"
        :byid="98676"
        :width="getScrollWidth"
        :scroll-src="publicUrls + 'free/style14/scrollIcon.png'"
      >
        <!-- 内容 -->
        <template #solidBorderExcon>
          <div
            class="right-scroll"
            ref="scrollBox"
            :style="list?.length <= 4 && { justifyContent: 'center', paddingLeft: '0px' }"
          >
            <div class="is-null" v-if="list.length === 0 && !loading">
              <span>暂无文创商品</span>
            </div>
            <div class="item-parent" v-else v-for="(item, index) in list" :key="item.id">
              <div class="scroll-item" @click="pathLink(item.url)">
                <img class="ex-top-left ex-icons" :src="publicUrls + 'free/style14/exhibitsIcon.png'" alt="" />
                <img class="ex-top-right ex-icons" :src="publicUrls + 'free/style14/exhibitsIcon.png'" alt="" />
                <img class="ex-bottom-left ex-icons" :src="publicUrls + 'free/style14/exhibitsIcon.png'" alt="" />
                <img class="ex-bottom-right ex-icons" :src="publicUrls + 'free/style14/exhibitsIcon.png'" alt="" />
                <div class="exImg-box">
                  <img
                    :src="$filters.getLinkUrl(item?.coverUrl, '?imageView2/3/w/560/format/webp')"
                    alt=""
                    class="empty-img"
                  />
                </div>
                <div class="exTitle">
                  {{ item.name }}
                </div>
                <div class="item-btm">
                  <span class="item-title3" v-if="item.price">参考价</span>
                  <span class="item-title1" v-if="item.price">￥</span>
                  <span class="item-title2" v-if="item.price">{{ item.price }}</span>
                  <span class="item-title4" v-if="!item.price">暂无价格</span>
                </div>
              </div>
            </div>
          </div>
        </template>
        <!-- 滚动条 -->
        <template #solidBorderExbar>
          <div class="solidBorder-child"></div>
        </template>
      </ScrollBoxCom>
    </div>
    <div class="content-door">
      <i class="iconfonts">&#xe6dd;</i>
      <span>永不落幕的展览与展示平台</span>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
export default defineComponent({
  name: 'style14',
});
</script>
<script lang="ts" setup>
// @ts-nocheck
import MenuNavigation from '@/freeComponents/menuNavigation/index.vue';
import { publicUrls, doorUrl } from '@/utils/minxin';
import { goodsList } from '@/api/goods/goods';
import RightMenu from '../components/rightMenu.vue';
import Logo from '../components/logo.vue';
import FooterHome from '../components/footerHome.vue';
import PublicTitle from '../components/PublicTitle.vue';
import { useRouter, useRoute } from 'vue-router';
import ScrollBoxCom from '../scrollBox.vue';
import { ref, watch, reactive, nextTick, defineComponent } from 'vue';
import { copyrightSave, copyrightInfo } from '@/api/templates/templates';
import { useProjectStore, commonDataStore } from '@/store';
import { storeToRefs } from 'pinia';
import { computed } from 'vue';
const parmas = reactive({
  value: '',
  pageNo: 1,
  pageSize: 100,
});
const topShow = ref(false);
const scrollBox = ref(null);
const percentage = ref(0);
const list = ref([]);
const total = ref(0);
const loading = ref(false);
const store = useProjectStore();
const Scrollwidth = ref();
const router = useRouter();
const route = useRoute();
const Description = ref('');
const init = async () => {
  try {
    if (loading.value) {
      return;
    }
    loading.value = true;
    let res = await goodsList(localStorage.getItem('projectId'), parmas);
    total.value = res.data.total;
    list.value = list.value.concat(res.data.data);
    // list.value = [];
    loading.value = false;
  } catch {
    loading.value = false;
  }
};
init();

let viewportwidth = window.innerWidth;
Scrollwidth.value = (viewportwidth / 900) * 1000;

const getScrollWidth = computed(() => {
  let rootNode = document.documentElement;

  // 获取计算后的样式
  let computedStyle = window.getComputedStyle(rootNode);

  // 读取字体大小（注意这里返回的可能是一个包含单位的字符串，如"16px"）
  let fontSize = computedStyle.fontSize;

  // 如果你需要一个数字值（不带单位）进行计算，你可能需要解析这个字符串
  // 例如，使用正则表达式或split()方法去除单位，并将结果转换为数字
  let fontSizeNumber = parseFloat(fontSize.replace(/[^0-9.-]/g, ''));
  let heights = (fontSizeNumber / 144) * 1000;
  return heights;
  // let widths = (window.innerWidth / 900) * 600;
  // return widths;
});
const getTabmComputed = computed(() => {
  let rootNode = document.documentElement;

  // 获取计算后的样式
  let computedStyle = window.getComputedStyle(rootNode);

  // 读取字体大小（注意这里返回的可能是一个包含单位的字符串，如"16px"）
  let fontSize = computedStyle.fontSize;

  // 如果你需要一个数字值（不带单位）进行计算，你可能需要解析这个字符串
  // 例如，使用正则表达式或split()方法去除单位，并将结果转换为数字
  let fontSizeNumber = parseFloat(fontSize.replace(/[^0-9.-]/g, ''));
  let heights = (fontSizeNumber / 144) * 180;
  return heights;
});
const handleScroll = (event) => {
  event.preventDefault(); // 阻止默认滚动行为
  const { deltaY } = event;

  // 获取滚动内容的 DOM 元素
  const contentEl = scrollBox.value;

  // 将滚动盒子向前滚动
  contentEl.scrollLeft += deltaY;
  if (contentEl.scrollWidth > contentEl.clientWidth) {
    if (
      contentEl.scrollWidth < contentEl.scrollLeft + contentEl.clientWidth + 100 &&
      !loading.value &&
      list.value.length < total.value
    ) {
      parmas.pageNo = parmas.pageNo + 1;
      init();
    }
    nextTick(() => {
      const { scrollLeft, clientWidth, scrollWidth } = scrollBox.value;
      if (scrollLeft > 100) {
        topShow.value = true;
      }
      if (scrollLeft < 100) {
        topShow.value = false;
      }
      const newScrollPercentage = Math.floor((scrollLeft / (scrollWidth - clientWidth)) * 100);
      percentage.value = newScrollPercentage == 99 ? 100 : newScrollPercentage;
    });
  }
};
const emitTop = () => {
  //点击回到列表最左侧
  scrollBox.value.scrollLeft = 0;
  percentage.value = 0;
  topShow.value = false;
};
const pathLink = (url?: string) => {
  if (!url) {
    return;
  }
  window.open(url, '_blank');
};
const blankHome = () => {
  router.push({ name: route.meta.loopType ? 'exhibitionHome' : 'templateedit' });
};
</script>

<style lang="less" scoped>
.cultural-box {
  position: relative;
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  padding: 116px 80px 58px 80px;
}
.content-door {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  cursor: pointer;
  .iconfonts {
    font-size: 26px;
    color: #fff;
    margin-bottom: 4px;
    line-height: 32px;
  }
  span {
    font-family: PingFang SC;
    font-size: 16px;
    line-height: 32px;
    color: #fff;
    margin-left: 20px;
    padding-bottom: 7px;
  }
}
.back-btn {
  position: absolute;
  top: 60px;
  left: 80px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}
.content-box {
  width: 100%;
  height: 100%;
  position: relative;
  padding: 130px 80px 80px 80px;
}
.public-name {
  position: absolute;
  top: -66px;
  left: 50%;
  transform: translateX(-50%);
  width: 370px;
  height: 116px;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 6px;
  img {
    width: 142px;
    height: 40px;
    flex-shrink: 0;
    object-fit: fill;
  }
}
.is-null {
  position: fixed;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 100%;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  span {
    font-size: 20px;
    line-height: 32px;
    color: #fff;
    opacity: 0.5;
  }
}
.right-scroll {
  display: flex;
  width: 100%;
  min-height: 381px;
  padding-left: 0px;
}
.item-parent {
  width: 300px;
  height: 440px;
  flex-shrink: 0;
  margin-right: 30px;
  &:last-child {
    margin: 0;
  }
}
.scroll-item {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  border: 2px solid #d4bb8f;
  background: radial-gradient(78.25% 76.86% at 50% 23.14%, #0054d4 0%, #002c6e 100%);
  margin-bottom: 42px;
  padding: 30px 26px 24px 26px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  cursor: pointer;
}
.ex-icons {
  position: absolute;
  width: 40px;
  height: 40px;
  object-fit: fill;
}
.ex-top-left {
  top: 10px;
  left: 10px;
}
.ex-top-right {
  top: 10px;
  right: 10px;
  transform: rotate(90deg);
}
.ex-bottom-left {
  bottom: 10px;
  left: 10px;
  transform: rotate(-90deg);
}
.ex-bottom-right {
  bottom: 10px;
  right: 10px;
  transform: rotate(180deg);
}
.exImg-box {
  flex-shrink: 0;
  width: 246px;
  height: 300px;
  border-radius: 16px;
  background: #d9d9d9;
  overflow: hidden;
  .empty-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: all 0.5s;
  }
}
.exImg-box:hover {
  .empty-img {
    transform: scale(1.2);
  }
}
.exTitle {
  width: 230px;
  overflow: hidden;
  color: #fff;
  text-align: start;
  text-overflow: ellipsis;
  font-family: 'Microsoft YaHei';
  font-size: 18px;
  font-style: normal;
  font-weight: 400;
  line-height: 36px; /* 200% */
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 16px;
}
.item-btm {
  // width: 121px;
  height: 34px;
  display: flex;
  align-items: flex-end;
  flex-shrink: 0;
  .item-title3,
  .item-title4 {
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    font-family: 'PingFang SC';
    font-size: 12px;
    font-style: normal;
    font-weight: 400;
    line-height: 24px; /* 200% */
    white-space: nowrap;
    padding: 0 0 4px 4px;
  }
  .item-title1,
  .item-title2 {
    color: #fff;
    text-align: center;
    font-family: 'SourceHanSerifCN';
    font-size: 22px;
    font-style: normal;
    font-weight: 700;
    white-space: nowrap;
    line-height: 34px; /* 154.545% */
  }
}
::v-deep .solid-box-parent {
  margin-top: 40px;
  img {
    width: 18px !important;
    height: 18px !important;
    margin-top: 6px !important;
    margin-left: 2px;
  }
}
.solidBorder-child {
  height: 2px;
  width: 100%;
  background: #19326d;
  flex-shrink: 0;
}
</style>
